
#ifndef _MEMBER_BMenuBar_H_
#define _MEMBER_BMenuBar_H_

#include <BRect>
#include <BStyle>
#include <BMenu>

namespace BWE
{
	class MenuBarItem
	{
	public:
		MenuBarItem()
		{
			menu = 0;
			dirty = false;
		}
		MenuBarItem(BMenu* menu)
		{
			this->menu = menu;
			dirty = true;
		}

		void freshSize(const BStyle* style, const BFont* font)
		{
			if (!font)
				return;

			if (menu->titleIcon())
				iconSize.set(font->size());
			else
				iconSize.reset();

			const BString& title = menu->title();
			if (style)
			{
				style->translate(title, t_title);
				if (t_title.size())
				{
					titleSize = font->textSize(t_title);
					return;
				}
			}
			titleSize = font->textSize(title);
		}
		bool operator == (const BMenu* menu)
		{
			return this->menu == menu;
		}

		bool		dirty;
		BMenu*		menu;
		BRect		rect;
		BSize		iconSize;
		BRect		iconRect;
		BRect		textRect;
		BSize		titleSize;
		BString		t_title;
	};

	class member_BMenuBar : public BObject
	{
		friend class BMenuBar;
	public:
		member_BMenuBar(BMenuBar* menuBar);
		~member_BMenuBar();

		void freshRects();

		void slotMenuAbleChanged(BObject* object, const BValue& value);
		void slotTitleChanged(BObject* object, const BValue& value);
		void slotTitleIconChanged(BObject* object, const BValue& value);

		BMenuBar*			boss;
		Align				align;
		Form				form;
		int					spacing;
		Orientation			orientation;
		Orientation			realOrient;

		bool				dirty;
		BSize				contentSize;
		int					hoverIndex;
		bool				pressed;
		BArray<MenuBarItem>	items;
	};
}

#endif